package com.tedu.domain.service.impl;


import com.tedu.domain.bo.ContentBO;
import com.tedu.domain.bo.ContentListBO;
import com.tedu.domain.repository.ContentRepository;
import com.tedu.domain.service.ContentService;
import com.tedu.protocol.param.ContentParam;
import com.tedu.protocol.param.ContentUpdateParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author liuhuan
* @description 针对表【content(内容表)】的数据库操作Service实现
* @createDate 2023-04-18 17:34:25
*/
@Service
@Slf4j
public class ContentServiceImpl implements ContentService {
    @Autowired
    private ContentRepository contentRepository;
    @Override
    public void addNew(ContentParam content) {
        log.info("开始处理新增内容逻辑");
        log.info("即将执行插入service");
        contentRepository.insert(content);
        log.info("业务逻辑处理成功");
    }
    @Override
    public int countByTitle(String title) {
       log.info("正在处理根据标题查找内容数量逻辑");
       int count= contentRepository.countByTitle(title);
       log.info("查询成功，受影响的数量为"+count);
       return count;
    }
    @Override
    public int deleteById(Integer id) {
        log.info("正在处理根据Id删除数据请求");
        int count= contentRepository.deleteById(id);
        log.info("处理完成");
        return count;
    }

    @Override
    public ContentBO selectByPrimaryKey(Integer id) {
        log.info("正在处理根据ID查询用户详细信息");
        return contentRepository.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ContentUpdateParam contentUpdateParam) {
        log.info("开始处理修改内容业务");
       int count= contentRepository.updateByPrimaryKeySelective(contentUpdateParam);
       log.info("修改完成");
        return count;
    }

    @Override
    public List<ContentListBO> list() {
        log.info("开始处理查询列表业务");
        List<ContentListBO> list=contentRepository.list();
        return list;
    }

}




